package com.hnevc.musicplayer;

import java.util.ArrayList;

public class MusicSystem {
	ArrayList<Music> musicList=new ArrayList();
	
	public MusicSystem() {
		
	}
	public MusicSystem(ArrayList<Music> musicList) {
		this.musicList=musicList;
	}
	public void shifTop(Music music) {
		musicList.remove(music);
		  musicList.add(0, music);  
    }  
    public void shiftBottom(Music music){  
        musicList.remove(music);  
        musicList.add(music);  
    }  
    public void shiftUp(Music music){  
        int index = musicList.indexOf(music);  
        musicList.remove(music);  
        index = index>0?index-1:0;  
        musicList.add(index,music);  
    }  
    public void shiftDown(Music music){  
        int index = musicList.indexOf(music);  
        index = index<musicList.size()-1?index+1:musicList.size();  
        musicList.remove(music);  
        musicList.add(index,music);  
    }  
    public void showMusic(){  
        System.out.println(musicList);  
    }  
    public Music  findMusic(String name){  
        for(Music m : musicList){  
            if(m.name .equals(name)){  
                return m;  
            }  
        }  
        return null;
	}
}
